import random
num = random.randint(1, 1000)
count = 0
while True:
    n = input("输入猜想数字(整数):")
    if n.isdigit():
        n = int(n)
        count += 1
        if num > n:
            print("猜小了")
        elif num < n:
            print("猜大了")
        else:
            print("猜对了，这个数字是{}".format(num))
            break
        if count % 3 == 0:
            print(f"本轮猜想次数为:{count}")
    else:
        print("输入内容错误，已退出")
        break
